package com.kaiwukj.android.ufamily.mvp.http.api.service;

import com.kaiwukj.android.ufamily.mvp.http.entity.base.BaseObjResp;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.LoginResult;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.UserResult;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.UserSimpleResult;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface AccountService {

    @GET("/admin/app/userAccount/sendVerifyCode/{phone}")
    Observable<BaseObjResp<Integer>> sendVerifyCode(@Path("phone") String mobile);

    @POST("/admin/sysLogin")
    Observable<BaseObjResp<LoginResult>> loginByPass(@Query("username") String username,
                                                     @Query("password") String password);

    @POST("/auth/mobile/token")
    Observable<BaseObjResp<LoginResult>> loginByCode(@Query("mobile") String mobile,
                                                     @Query("code") String code,
                                                     @Query("grant_type") String grant_type);

    @POST("/auth/mobile/token")
    Observable<BaseObjResp<LoginResult>> loginByWechat(@Query("openId") String openId,
                                                       @Query("mobile") String mobile,
                                                       @Query("code") String code,
                                                       @Query("grant_type") String grant_type);

    @POST("/auth/mobile/token")
    Observable<BaseObjResp<LoginResult>> loginByFast(@Query("token") String token,
                                                     @Query("opToken") String opToken,
                                                     @Query("operator") String operator,
                                                     @Query("grant_type") String grant_type);

    @FormUrlEncoded
    @PUT("/admin/app/userAccount/backPassword")
    Observable<BaseObjResp<Integer>> updatePwd(@Field("newPassword") String pwd);

    @GET("/admin/app/userAccount/info")
    Observable<BaseObjResp<UserResult>> getUserInfo();

    @GET("/admin/app/userAccount/{id}")
    Observable<BaseObjResp<UserResult>> getUserById(@Path("id") int id);

    @GET("/admin/app/userAccount/getUserInfoByHxName/{hxName}")
    Observable<BaseObjResp<UserSimpleResult>> getUserByHxName(@Path("hxName") String hxName);

    @PUT("/admin/app/userAccount/updateUserInfo")
    Observable<BaseObjResp<Integer>> updateUserInfo(@Body RequestBody body);

}
